#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""模拟资源API路由模块（已注释）

注意：根据要求，模拟数据相关代码已全部注释，不再使用模拟数据。
所有数据将从数据库获取，确保真实性和实用性。
"""

# from flask import Blueprint, request, jsonify, send_file, make_response
# import os
# import logging
# import base64
# from io import BytesIO
# from PIL import Image, ImageDraw, ImageFont
# import random

# # 创建蓝图
# mock_bp = Blueprint('mock', __name__, url_prefix='/mock')

# # 配置日志
# logger = logging.getLogger(__name__)

# def generate_placeholder_image(width=300, height=200, text="Alert Image"):
#     """生成占位图片
#     
#     Args:
#         width: 图片宽度
#         height: 图片高度
#         text: 图片上显示的文本
#         
#     Returns:
#         图片的BytesIO对象
#     """
#     # 创建空白图片
#     img = Image.new('RGB', (width, height), color=(random.randint(200, 230), random.randint(200, 230), random.randint(200, 230)))
#     
#     # 创建绘图对象
#     draw = ImageDraw.Draw(img)
#     
#     # 尝试加载字体，如果失败则使用默认字体
#     try:
#         # 使用默认字体
#         font_size = min(width, height) // 8
#         # 简单的文本居中
#         text_bbox = draw.textbbox((0, 0), text)
#         text_width = text_bbox[2] - text_bbox[0]
#         text_height = text_bbox[3] - text_bbox[1]
#         text_x = (width - text_width) // 2
#         text_y = (height - text_height) // 2
#         
#         # 绘制文本
#         draw.text((text_x, text_y), text, fill=(70, 70, 70))
#     except Exception as e:
#         logger.warning(f"无法创建文本: {str(e)}")
#     
#     # 保存到BytesIO
#     img_io = BytesIO()
#     img.save(img_io, format='JPEG')
#     img_io.seek(0)
#     return img_io

# @mock_bp.route('/images/<path:filename>', methods=['GET'])
# def get_mock_image(filename):
#     """获取模拟图片
#     
#     Args:
#         filename: 图片文件名
#         
#     Returns:
#         模拟的图片文件
#     """
#     try:
#         logger.info(f"请求模拟图片: {filename}")
#         
#         # 从文件名中提取告警ID（如果有）
#         alert_id = None
#         if filename.startswith('alert_'):
#             # 提取alert_后面的数字部分
#             alert_number = filename.split('_')[1].split('.')[0]
#             alert_id = f"ALERT-{alert_number}"
#             text = f"告警图片 {alert_id}"
#         else:
#             text = "模拟图片"
#         
#         # 生成占位图片
#         img_io = generate_placeholder_image(width=640, height=480, text=text)
#         
#         # 返回图片
#         response = make_response(send_file(img_io, mimetype='image/jpeg'))
#         response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
#         response.headers['Pragma'] = 'no-cache'
#         response.headers['Expires'] = '0'
#         
#         return response
#     except Exception as e:
#         logger.error(f"生成模拟图片失败: {str(e)}")
#         return jsonify({'error': '无法生成模拟图片'}), 500

# @mock_bp.route('/health', methods=['GET'])
# def mock_health_check():
#     """模拟资源健康检查"""
#     return jsonify({
#         'status': 'healthy',
#         'service': 'mock-resources',
#         'message': '模拟资源服务正常运行'
#     })